package TetrisFlash.InGameManager 
{
	import TetrisFlash.Objects.TetrisBoard.TetrisBoard;
	import TetrisFlash.Objects.Tetrominoes.ITetromino;
	import TetrisFlash.Objects.Tetrominoes.TetrominoI;
	import TetrisFlash.Objects.Tetrominoes.TetrominoL1;
	import TetrisFlash.Objects.Tetrominoes.TetrominoL2;
	import TetrisFlash.Objects.Tetrominoes.TetrominoO;
	import TetrisFlash.Objects.Tetrominoes.TetrominoT;
	import TetrisFlash.Objects.Tetrominoes.TetrominoZ1;
	import TetrisFlash.Objects.Tetrominoes.TetrominoZ2;
	import TetrisFlash.Screen.Screen;
	import TetrisFlash.Utilities.RandomNumberHelper;
	/**
	 * ...
	 * @author DANTRUONG
	 */
	public class ManagerRunGame 
	{
		public var boardTetris:TetrisBoard;
		public var tetrominoTetris:ITetromino;
		
		public var score: int;
		public var nextScore:int;
		public var level: int;
		public var curSpeedDown:int;
		public var speedDown:int;
		
		public var arrayCount:Array;
		
		public var nextTetromino:int;
		public var holdTetromino:int;
		
		public var isHold:Boolean;
		
		public function ManagerRunGame(screen: Screen) 
		{
			boardTetris = new TetrisBoard(screen);
			
			var ID:int = RandomNumberHelper.randomIntRange(1, 7);
			
			switch(ID) {
				case 1:
					tetrominoTetris = new TetrominoI(screen);
					break;
				case 2:
					tetrominoTetris = new TetrominoL1(screen);
					break;
				case 3:
					tetrominoTetris = new TetrominoL2(screen);
					break;
				case 4:
					tetrominoTetris = new TetrominoO(screen);
					break;
				case 5:
					tetrominoTetris = new TetrominoT(screen);
					break
				case 6:
					tetrominoTetris = new TetrominoZ1(screen);
					break;
				case 7:
					tetrominoTetris = new TetrominoZ2(screen);
					break;
			}
			tetrominoTetris.init();
			score = 0;
			nextScore = 200;
			level = 1;
			curSpeedDown = 0;
			speedDown = 30;
			arrayCount = new Array();
			arrayCount[0] = arrayCount[1] = arrayCount[2] = arrayCount[3] = 0;
			nextTetromino = RandomNumberHelper.randomIntRange(1, 7);
			holdTetromino = 0;
			isHold = false;
		}
		
		public function ReleaseManagerRunGame():void {
			tetrominoTetris.release();
			boardTetris.release();
			arrayCount = [];
		}
		
	}

}